package com.yingcheng.numerology.framework.bazi.core.enums;

import cn.hutool.core.util.ArrayUtil;
import java.util.Arrays;
import lombok.Getter;
import lombok.RequiredArgsConstructor;

/**
 * 十天干
 *
 * @author xiaofeng
 * @date 2024/11/7 14:17
 */
@Getter
@RequiredArgsConstructor
public enum HeavenlyStemsEnum implements FieldEnumerable<HeavenlyStemsEnum> {

    JIA("甲", "jia", 1,YinYangEnum.YANG, ElementsEnum.WOOD),
    YI("乙", "yi", 2,YinYangEnum.YIN, ElementsEnum.WOOD),
    BING("丙", "bing", 3,YinYangEnum.YANG, ElementsEnum.FIRE),
    DING("丁", "ding", 4,YinYangEnum.YIN, ElementsEnum.FIRE),
    WU("戊", "wu", 5,YinYangEnum.YANG, ElementsEnum.EARTH),
    JI("己", "ji", 6,YinYangEnum.YIN, ElementsEnum.EARTH),
    GENG("庚", "geng", 7,YinYangEnum.YANG, ElementsEnum.METAL),
    XIN("辛", "xin", 8,YinYangEnum.YIN, ElementsEnum.METAL),
    REN("壬", "ren", 9,YinYangEnum.YANG, ElementsEnum.WATER),
    GUI("癸", "gui", 10,YinYangEnum.YIN, ElementsEnum.WATER);

    public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(HeavenlyStemsEnum::getIndex).toArray();

    /**
     * 名称
     */
    private final String name;

    /**
     * 编码
     */
    private final String code;

    /**
     * index
     */
    private final Integer index;

    /**
     * 阴阳
     */
    private final YinYangEnum yinYang;

    /**
     * 五行
     */
    private final ElementsEnum fiveElements;


    /**
     * 根据index获取对象
     *
     * @param index
     * @return
     */
    public static HeavenlyStemsEnum getByIndex(final Integer index) {
        return ArrayUtil.firstMatch(heavenlyStemsEnum -> heavenlyStemsEnum.getIndex().equals(index),values());
    }

}
